#include <iostream>
#include <ctime>
#include <cstdlib>
#include <string>
#include <set>
#include <algorithm>

int const upper = 2;
int n = 15;
std::string s(n, 'a');
std::string tt(n, 'z');

bool judge(std::string const & s)
{
	std::string t = s;
	std::reverse(t.begin(), t.end());
	return s == t;
}

int main()
{
	std::srand(std::time(0));
	std::set<int> pos;
	for (int ti = 0; ti <= 50000; ti++) {
		for (int i = 0; i < n; i++)
			s[i] = rand() % upper + 'a';

		std::set<std::string> all;
		for (int i = 0; i < n; i++)
			for (int j = 1; i + j - 1 < n; j++) {
				std::string tmp = s.substr(i, j);
				if (judge(tmp)) all.insert(tmp);
			}
		pos.insert(all.size());
		if (all.size() == 9) {
			if (s < tt) tt = s;
		}
	}
	for (auto i : pos)
		std::cout << i << ' ';
	std::cout << '\n';
	std::cout << tt << '\n';
}

